-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encryption component #11
Conversation
Development to main
Add NFT Tokens
Cleanup package.json
Revert "Cleanup package.json"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
import {v4 as uuidv4} from "uuid"; | ||
const crypto = require("crypto"); | ||
|
||
export class Randomness { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ I confirm there's no change in the logic of this class (only move / refactor).
@@ -0,0 +1,36 @@ | |||
import scryptsy from "scryptsy"; | |||
|
|||
export class ScryptKeyDerivationParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm there's no change in logic - only movement & refactoring ✔️ (better cohesion now).
src/walletcore/userWallet.ts
Outdated
private static generateDerivedKey(password: Buffer, salt: Buffer, kdfparams: ScryptKeyDerivationParams): Buffer { | ||
const derivedKey = scryptsy(password, salt, kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); | ||
return derivedKey; | ||
static ecFromJSON(keyfileObject: any): EncryptedData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the prefix ec
mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a typo, should have been ed
for "Encrypted Data"
@@ -0,0 +1,22 @@ | |||
import { assert } from "chai"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for this test.
|
||
const decipher = crypto.createDecipheriv(data.cipher, derivedKeyFirstHalf, iv); | ||
|
||
return Buffer.concat([decipher.update(ciphertext), decipher.final()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the padding is still done in userWallet.ts
.
I can confirm there's no change in logic - only refactoring ✔️
|
||
export class Encryptor { | ||
public static encrypt(data: Buffer, password: string, randomness: Randomness = new Randomness()): EncryptedData { | ||
const kdParams = new ScryptKeyDerivationParams(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm the login here is the one from the previous constructor of UserWallet
✔️
Added new component for
EncryptedData
.It uses the same key derivation mechanism as the account keyfile (in fact, that was refactored to use
EncryptedData
under the hood which is more general-purpose).Link to component description:
https://docs.google.com/document/d/1Xxb39JJkf8B9UzzQZd3KeOzL6nomoOxOyxKpxDKRgiE/edit#